<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            height: 20px;
        }
    </style>
</head> 
<body>
    <button>头条</button>
    <button>科技</button>
    <button>美食</button>
    <button>娱乐</button>

    <div>聚焦</div>
    <script>
       const btns=document.querySelectorAll('button')
       btns.forEach((item)=>{
        item.addEventListener('click',function(){
            btns.forEach((v)=>{
                v.style.backgroundColor=''
            })
            item.style.backgroundColor='red'
        })
       })

       const div=document.querySelector('div')
       div.setAttribute('tabindex', '0');
       div.addEventListener('focus',function(){
        this.style.backgroundColor='red'
       })
       const div1=document.getElementsByName('div')
       console.log(div1.values)
    </script>
</body>
</html>
